home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: hku.open-forum,hku.cc.forum,hk.comp.pc,comp.lang.c++,comp.lang.pascal.misc
- Path: hkusuc.hku.hk!pc
- From: kong@hkusua.hku.hk (someone)
- Subject: Re: Is Pascal worth to learn? Can it help me to get a job?
- X-Nntp-Posting-Host: 147.8.35.29
- Message-ID: <4devt9$844_001@news.hku.hk>
- Sender: usenet@hkusuc.hku.hk
- Organization: The University of Hong Kong
- X-Newsreader: News Xpress Version 1.0 Beta #4
- References: <30f2adf8.7810115@news.hku.hk> <DL2tFM.7DJ@hkuxb.hku.hk>
- <4dcrl0$7mo_001@news.hku.hk> <SDLEE.96Jan15161338@champion.cs.hku.hk>
- Date: Tue, 16 Jan 1996 01:44:09 GMT
-
- In article <SDLEE.96Jan15161338@champion.cs.hku.hk>,
- sdlee@cs.hku.hk (Lee Sau Dan ~{@nJX6X~}) wrote:
-
- >
- > >> For example, in C I can swap two integers a and b without
- > >> using a temporary variable in three statements: a ^= b; b ^= a;
- > >> a^= b , I can also use bit-vectors.
- >
- >This method of swapping is not as easy to understand as the method of
- >using a temp. variable. Moreover, bit-vectors are for memory
- >optimization (and, to a certain extent speed optimization). They are
- >difficult to debug and maintain and do not generalize to other
- >problems. (E.g. when you swap to strings, you cannot use your proposed
- >method.) This is not a good programming practice.
-
- I do agree using the swapping method I mentioned is not a common practice
- (and I myself never have to do it). But it does demonstrate the power of
- a language.
-
- Bit-vectors ARE required in many cases, and I strongly disagree that they
- are difficult to debug or maintain. There are cases when there will be
- matrixes with hundreds or at times millions of elements, each containing just
- a few boolean values. It will be much easier to debug and maintain the code
- by using bit-vectors and use masks defined as constants to set or get the
- required bits. Not to mention the memories saved compared to using arrays
- of booleans.
-
- >
- >So, to a beginner, these limitations are advantageous. They train
- >a programmer to write more structurally and maintainably.
- >
- >
- > >> I can have generic pointers that may point to everything or
- > >> nothing.
- >
- >Well... when you use such pointers, bear in mind the potential problems
- >and bugs that may result. Such pointers bypasses the strong type-checking
- >mechanism of the language. Think twice and before using such pointers.
- >They are often better ways to do the same thing.
-
- Er.. right. While I said that in my post I was responding to the original
- poster's claim that Pascal can do everything other language can do. The
- ability to cast a pointer to something else is a two side sword. A good
- programmer can make use of it wisely. Lousy programmers make pointer
- errors out of it. (This is one reason why there is no pointer in Java.)
- However I do wonder there are cases generic pointers help a lot. That's why
- you say "often" instead of "always".
-
-
- >
- >
- > >> I can have arrays with no compile-time defined sizes.
- >
- >Beware of out-of-bound array references, then! BTW, does C support
- >multi-dimensional arrays cleanly so that they can be passed into
- >procedures?
- >
-
- Out-of-bound array references can happen in Pascal, if you turn-off
- your run-time array bound checking. Again, pointers arithmetic in
- C is a two side sword.
-
- >
- > >> AFAIK there are no way of doing such things in Pascal. At least
- > >> not in standard Pascal. There are also many fallbacks in Pascal
- > >> that are inconvenient for programmers,
- >
- >Well... They are not always inconvenient for programers. Very often,
- >they help to prevent bugs early.
- >
- >
- > >> e.g. no break within loops. That's why there are things like
- > >> Modula-2.
- >
-
-
- -- All opinions are mine, they do not reflect standings of my employer.
-